package info.fqtech.study.createpattern.protoype;

/**
 * @author YASSER   作者 E-mail:   450153554@qq.com
 * @date: 2018-12-24 10:51
 * @version: 1.0.0
 * @description: <文件描述>
 * @modified: <文件修改说明>
 */
public class Prototype implements Cloneable {

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected Object clone() {
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public String toString() {
        return "Prototype{" +
                "name='" + name + '\'' +
                '}';
    }

    public static void main(String[] args) {
        Prototype prototype1 = new Prototype();

        prototype1.setName("jack");

        Prototype prototype2 = (Prototype) prototype1.clone();

        System.out.println(prototype1);
        System.out.println(prototype2);
    }
}
